package persistence;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Date;

public class BookingTDG 
{

	//methods
	public static ArrayList<BookingFascade> FindAll()
	{
		ArrayList<BookingFascade> BookingsFascade = new ArrayList<BookingFascade>(30);
		
		FileStorageRegistry.GetInstance().CheckFilesExist("src/bookings.txt");
		
		File events = new File("src/bookings.txt");

        try 
        {
        	BufferedReader reader = new BufferedReader(new FileReader(events));

        	String TotalPpl="";
        	String CustomerID="";
        	String EventID="";

        	while(reader.ready())
        	{
        		TotalPpl = reader.readLine();
        		CustomerID = reader.readLine();
        		EventID = reader.readLine();

        		int TotalPplint = Integer.parseInt(TotalPpl);
        		int CustomerIDint = Integer.parseInt(CustomerID);
        		int EventIDint = Integer.parseInt(EventID);
        	
        		BookingsFascade.add(new BookingFascade(CustomerIDint,TotalPplint,EventIDint));
        		
        		reader.readLine(); //skips past '-' of txt file
        	}

        	reader.close();
        } 
        
        catch (Exception e) 
        {
            System.err.println(e);
            System.exit(1);
        }
		
		return BookingsFascade;
	}
}
